const path = require('path');
const isDev = think.env === 'development';
const config = require('./config')
const proxy = require('./../middleware/proxy')
module.exports = [
  {
    handle: 'meta',
    options: {
      logRequest: isDev,
      sendResponseTime: isDev
    }
  }, {
    handle: 'resource',
    enable: isDev,
    options: {
      root: path.join(think.ROOT_PATH, 'www'),
      publicPath: /^\/(static|upload|favicon\.ico)/
    }
  }, {
    handle: 'trace',
    enable: !think.isCli,
    options: {
      debug: isDev
    }
  }, {
    handle: 'payload',
    options: {}
  }, {
    handle: 'router',
    options: {}
  },
  {
    handle: proxy,
    options: {
      api: {
        github_api: 'https://api.github.com/',
        github: 'https://github.com/',
        localhost: 'http://localhost:8366/'
      },
      options: {
        timeout: config.proxy.timeout // 接口超时时间
      }
    } // 代理配置
  },
  'logic',
  'controller'
];
